<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <div id="demo">
    <h1>测试</h1>
    <p>foo:{{foo}}</p>
    <p>bar:{{bar}}</p>

    <child-component :message="123" @child-click="fromHandleChild" @click.once="parentClick"></child-component>
  </div>
  <script src="../../dist/vue.js"></script>
  <script>
    const app = new Vue({
      el: '#demo',
      provide: {
        foo: 'Tony'
      },
      data: {
        foo: '1',
        bar: '20'
      },
      mounted() {
        this.foo = '333333333';
        this.bar = '3000000000000'
      },
      methods: {
        fromHandleChild() {
          console.log('子组件点击')
        },
        parentClick() {
          console.log('父组件点击')
        }
      }
    })
    Vue.component('child-component', {
      inject: ['foo'],
      props: {
        message: {
          type: Number,
        }
      },
      data: function () {
        return {
          count: 0
        }
      },
      mounted() {
        this.count = '44444444'
      },
      methods:{
        handleChild() {
          this.$emit('child-click')
        }
      },
      template: '<div @click="handleChild">组件{{count}}</div>'
    })
    console.log(app.$options.render)
  </script>
</body>
</html>